<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        main{
            position: relative;
            width: 100vw;
            height: 100vh;
            background: linear-gradient(to right,#000 50%,#fff 50%);
        }
        .background{
            width: 50%;
            height: 100%;
        }

        #font{
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%);
            width: 400px;
            height: 100px;
            text-align: center;
            line-height: 100px;
            font-size: 28px;
            font-weight: bold;
            /* 一定要定义文字颜色为白色 */
            color: #fff;
            /* 关键属性 混合模式 difference颜色反转*/
            mix-blend-mode: difference;
        }
    </style>
</head>
<body>
    <main>
        <div id="font">mix-blend-mode</div>
    </main>
</body>
</html>